home *** CD-ROM | disk | FTP | other *** search
/ United Public Domain Gold 2 / United Public Domain Gold 2.iso / business / pb016.dms / pb016.adf / Config!R < prev    next >
Text File  |  1992-06-18  |  9KB  |  311 lines

  1. -----------------------------------------------------------------------------
  2. |                              Config!R                                        |
  3. |         Copyright (C) 1986-92 Rick Stiles.  All rights reserved.            |
  4. -----------------------------------------------------------------------------
  5.  
  6. *************************************
  7. N-variables used:
  8. n0-n1scratch numbers
  9. n26 used by rexx
  10. n27 action/result
  11. n28 rexx flag
  12. n29 rexx return code
  13.  
  14. Buffers used:
  15. buf50 & buf51    scratch buffers
  16.  
  17. buf36    REXXCOMM buf
  18. buf49    search buf
  19. buf61    rexx in buf
  20. buf62    rexx out buf
  21.  
  22. *************************************
  23.  
  24. <defines:
  25. define(N_0,n0)
  26. define(N_1,n1)
  27. define(RX_VAR,n26)
  28. define(ACT_RESULT,n27)
  29. define(FLAG_BITS,n28)
  30. define(RTN_CODE,n29)
  31. define(NSTACK_99,n99)        .. note n99 not really used
  32. define(B_0,buf50)
  33. define(B_1,buf51)
  34. define(BSTACK_99,buf99)     .. note buf99 not really used
  35. define(REXX_COMM_BUF,buf36)
  36. define(SEARCH_STR,buf49)
  37. define(REXX_IN_BUF,buf61)
  38. define(REXX_OUT_BUF,buf62)
  39. >
  40.  
  41.  
  42. ======= AREXX CMDS ======
  43. Major modifications to this file by Kerry Zimmerman [71470,1340] 4/14/89
  44. o  Changed output buffer to 62, input buffer to 61 to avoid conflict with
  45.    Eric Kennedy's VI extensions.
  46. o  altctl-0 now asks for a command name and a list of macronums.
  47.    It adds these to the end of file U:REXXCOMM.  This file is a database
  48.    of macros understood by the new rexx autotraffic handler.
  49.  
  50. Edit Rexx output buffer 62
  51. <altCtl-1:
  52.     equateLoc(REXX_OUT_BUF,sPage,sFile)
  53.     editBuf(REXX_OUT_BUF) >
  54.  
  55. Edit Rexx input buffer 61
  56. <altCtl-2:
  57.     equateLoc(REXX_IN_BUF,sPage,sFile)
  58.     editBuf(REXX_IN_BUF) >
  59.  
  60. Send output buffer 62 to Rexx
  61. <altCtl-3:
  62.     equateNum(FLAG_BITS,0)                     .. 0 flag means send msg, not reply
  63.     rexxOut(REXX_OUT_BUF,all,0,FLAG_BITS,RTN_CODE)   .. 0 ActionResult means default to RXCOMM
  64.     runKey(virtual-s) >
  65.  
  66. Fetch Rexx input into buffer 61
  67. <altCtl-4:
  68.     if (rexxIn(REXX_IN_BUF,sFile,ACT_RESULT,FLAG_BITS,RTN_CODE)) {
  69.         ..if (eqNum(FLAG_BITS,0)) {       .. if Msg
  70.             equateLoc(REXX_IN_BUF,sPage,sFile)
  71.             editBuf(REXX_IN_BUF)
  72.         ..}
  73.      }
  74.      runKey(virtual-r) >
  75.  
  76. Send hilite region to Rexx.
  77. <altCtl-5:
  78.     equateNum(FLAG_BITS,0)                               .. 0 means msg, not reply
  79.     rexxOut(curFile,hilite,0,FLAG_BITS,RTN_CODE)  .. 0 means default to Action = RXCOMM
  80.     runKey(virtual-s) >
  81.  
  82. Fetch Rexx input at cursor
  83. <altCtl-6:
  84.     rexxIn(curFile,atCursor,ACT_RESULT,FLAG_BITS,RTN_CODE)
  85.     runKey(virtual-r) >
  86.  
  87. Send an OK reply to Rexx  (NOTE: Amiga-ESC abort sends Failed reply.)
  88. <altCtl-7:
  89.     equateNum(FLAG_BITS,1)                               .. 1 means reply, not msg
  90.     rexxOut(" ",all,0,FLAG_BITS,RTN_CODE)                            .. 0 is OKAY result
  91.     runKey(virtual-s) >
  92.  
  93. Send an OK reply to Rexx along with text in hilite region
  94. <altCtl-8:
  95.     equateNum(FLAG_BITS,1)
  96.     rexxOut(curFile,hilite,0,FLAG_BITS,RTN_CODE) ..text NOT sent, if not RXFB_RESULT msg
  97.     runKey(virtual-s) >
  98.  
  99. Make an x.rexx program with commands to send to Uedit.
  100. <altCtl-0:
  101.     freebuf(REXX_COMM_BUF)
  102.     if (!loadfile("REXXCOMM")) loadfile("S:REXXCOMM")
  103.     movecursor(curFile,eFile)
  104.     putmsg("Enter new command's name")
  105.     freebuf(B_0)
  106.     inputString(B_0)
  107.     insertRgn(curFile,atCursor,B_0,all)
  108.     insertRgn(curFile,atCursor,"        |
  109. ",all)
  110.     movecursor(curFile,sChar)
  111.     movecursor(curFile,sChar)
  112.     updateDisplay
  113.     while (nothing) {
  114.         putMsg("Give desired inputs.  Amiga-ESC when done.  F2 to save.")
  115.         getKeyVal(macroNum,inputChar)
  116.         toWord(curFile,macroNum)
  117.         insertChar(curFile,"+")
  118.         toWord(curFile,inputChar)
  119.         insertChar(curFile," ")
  120.         updateDisplay
  121.         fileSize(curFile,N_0) .. force pack, avoid mem-abort
  122.     }
  123. >
  124.  
  125. <virtual-t:     .. swap this into rexxKey cmd when autoTraffic is used.
  126.     if (rexxIn(REXX_IN_BUF,eFile,ACT_RESULT,FLAG_BITS,RTN_CODE)) {           .. if fetched something
  127.         ..runKey(virtual-r)         .. show flags - slower if use this line
  128.         if (eqNum(FLAG_BITS,0)) {                    .. if recvd a Msg, not a Reply
  129.  
  130.             equateNum(RX_VAR,0)
  131.             push(NSTACK_99,searchCaps)     .. (RS mod)
  132.             equateNum(searchCaps,0) .. turn off case sensitivity (RS mod)
  133.             runkey(virtual-y)
  134.             pop(RTN_CODE,searchCaps)      .. restore orig case sensitivity (RS mod)
  135.             freeBuf(REXX_IN_BUF)
  136.             if(not eqNum(RX_VAR,0)) return .. comand already sent a reply
  137.             if(eqLoc(curFile,sInvert,eInvert)) goto label(50)
  138.             rexxOut(curFile,Invert,0,1,RTN_CODE) .. search uses this as an example
  139.             return
  140.  
  141. label(50)    rexxOut(" ",all,0,1,RTN_CODE)
  142.         }
  143.     }
  144. >
  145.  
  146. handle named macro messages
  147. <virtual-y:
  148. .. if REXX_COMM_BUF doesn't contain the named commands yet
  149. .. read it in
  150.     moveCursor(REXX_COMM_BUF,sfile)
  151.     freeBuf(B_0)
  152.     insertRgn(B_0,atCursor,"REXXCOMM",all)
  153.             setSearch(B_0)
  154.             if(not search(REXX_COMM_BUF,sHilite,eHilite,1)) {
  155.         freeBuf(REXX_COMM_BUF)
  156.         if(!insertFile(REXX_COMM_BUF,sfile,"REXXCOMM")
  157.             & !insertFile(REXX_COMM_BUF,sfile,"S:REXXCOMM")) {
  158.             putmsg("file REXXCOMM not found")
  159.             returnFalse
  160.         }
  161.     }
  162.  
  163. .. extract 1st word of REXX_IN_BUF which is the command
  164.     moveCursor(REXX_IN_BUF,sfile)
  165.     equateLoc(REXX_IN_BUF,sHilite,atCursor)
  166.     moveCursor(REXX_IN_BUF,eWord)
  167.     equateLoc(REXX_IN_BUF,eHilite,atCursor)
  168.     freebuf(B_0)
  169.     insertRgn(B_0,sFile,REXX_IN_BUF,Hilite) ..save command
  170.  
  171.     clearRgn(REXX_IN_BUF,Hilite) ..erase command leaving any args
  172.     while(is(REXX_IN_BUF,whiteSpace))
  173.         clearChar(REXX_IN_BUF)
  174.     setSearch(B_0)
  175.  
  176. .. search for this command in list of commands in REXX_COMM_BUF
  177.     moveCursor(REXX_COMM_BUF,sfile)
  178.     moveCursor(REXX_COMM_BUF,eLine) .. start search after 1st line
  179.     if(not search(REXX_COMM_BUF,sHilite,eHilite,1)) {
  180.         freeBuf(B_1)
  181.         insertRgn(B_1,efile,"REXX command NOT found: ",all)
  182.         insertRgn(B_1,efile,B_0,all)
  183.         returnFalse
  184.     }
  185.  
  186. .. move to the first macronum
  187.     moveCursor(REXX_COMM_BUF,eHilite)
  188.  
  189. .. process each macronum+inputchar pair until "|" found
  190.  
  191. label(10)
  192.     while(is(REXX_COMM_BUF,whitespace))
  193.         moveCursor(REXX_COMM_BUF,echar)
  194. .. return if end of commands
  195.     if(is(REXX_COMM_BUF,"|") | is(REXX_COMM_BUF,eFile)) returnTrue
  196.  
  197. .. convert xx+yy to macronum-xx, inputchar-yy
  198.     equateNum(macroNum,0)
  199.     equateNum(inputChar,0)
  200.     if(is(REXX_COMM_BUF,digit)) {
  201.         toNumber(macroNum,REXX_COMM_BUF)
  202.         while(is(REXX_COMM_BUF,digit))
  203.             moveCursor(REXX_COMM_BUF,echar)
  204.         if(is(REXX_COMM_BUF,"+")){
  205.             moveCursor(REXX_COMM_BUF,echar)
  206.             if(is(REXX_COMM_BUF,digit)){
  207.                 toNumber(inputChar,REXX_COMM_BUF)
  208.                 while(is(REXX_COMM_BUF,digit))
  209.                     moveCursor(REXX_COMM_BUF,echar)
  210.             }
  211.         }
  212.     }
  213.     .. run valid macroNum, or type valid inputChar
  214.     if(inUse(macroNum)) runKey(macroNum)
  215.     else if(gtNum(inputChar,0)) TypeChar(inputChar)
  216.     else return
  217.     goto label(10) >
  218.  
  219.  
  220. Show numbers for a received Arexx msg or reply
  221. <virtual-r:
  222.     if (not eqNum(RTN_CODE,0)) runKey(virtual-m)           .. rexxIn() failed
  223.     else {                                         .. rexxIn() succeeded
  224.         if (eqNum(FLAG_BITS,0)) {               .. MSG: show action & modifiers
  225.             and(RX_VAR,ACT_RESULT,0X0F000000)                 .. get ACTION code
  226.             and(N_1,ACT_RESULT,0X000F0000)                .. get MODIFIER
  227.             if(gtNum(N_1,0)) div(N_1,N_1,0x10000)
  228.             freeBuf(B_1)
  229.             insertRgn(B_1,atCursor,"Msg fetched:  Action = ",all)
  230.             toWord(B_1,RX_VAR)
  231.             insertRgn(B_1,atCursor,"  Modifier = ",all)
  232.             toWord(B_1,N_1)
  233.             ..insertRgn(B_1,atCursor,"  -- press return",all)
  234.             putMsg(B_1)
  235.         } else {                                              .. REPLY:
  236.             if (eqNum(ACT_RESULT,0)) putMsg("Reply fetched.  Result OKAY")
  237.             else {
  238.                 freeBuf(B_1)
  239.                 insertRgn(B_1,atCursor,
  240.                     "Reply received:  Result = ERROR ",all)
  241.                 toWord(B_1,ACT_RESULT)
  242.                 ..insertRgn(B_1,atCursor,"  -- press return",all)
  243.                 putMsg(B_1)
  244.             }
  245.         }
  246.     }
  247. ..getkey(N_0)
  248. >
  249.  
  250. Show numbers for a sent ARexx msg or reply
  251. <virtual-s:
  252.         if (not eqNum(RTN_CODE,0)) runKey(virtual-m)          .. rexxOut() failed
  253.         else {
  254.             if (eqNum(FLAG_BITS,0)) putMsg("Msg sent")
  255.             else              putMsg("Reply sent")
  256.         }
  257. >
  258.  
  259. Show returncode error msgs
  260. <virtual-m:
  261.     switch(RTN_CODE) {
  262.     case(-1) { putMsg("ARexx not up") }
  263.     case(-2) { putMsg("No memory or no text") }
  264.     case(-3) { putMsg("Msg/reply > 65535 bytes") }
  265.     case(-4) { putMsg("Nothing to fetch or reply to") }
  266.     case(-5) { putMsg("Fetch reply before sending this msg/reply") }
  267.     }
  268.     returnFalse                   .. so virtual-r/-s above will return False
  269. >
  270.  
  271. ====================================================================
  272. Some useful functions for the arexx macros
  273.  
  274. The 'ask' macro.  Usage:  ask 'Do you want to continue?'
  275. ask a question and return true or false
  276. <virtual-i:
  277.     equateNum(RX_VAR,1)
  278.     if(askYesNo(REXX_IN_BUF))
  279.         rexxOut("YES",all,0,1,RTN_CODE)
  280.     else
  281.         rexxOut("NO",all,0,1,RTN_CODE)
  282. >
  283.  
  284. the 'text' macro.  Usage:  text 'this will be inserted'
  285. insert text at cursor
  286. <virtual-h: insertRgn(curFile,atCursor,REXX_IN_BUF,all)
  287.             updatedisplay>
  288.  
  289. the 'loadfile' macro.  Usage: loadfile 'sys:myfile'
  290. edit given file
  291. <virtual-j:    loadfile(REXX_IN_BUF)>
  292.  
  293. the 'gotoline' macro  Usage: gotoline 100
  294. goto line
  295. <virtual-n:    toNumber(N_0,REXX_IN_BUF) lineToLoc(curFile,atCursor,N_0) >
  296.  
  297. the 'searchfor' macro  Usage: searchfor pattern
  298. search for a given string
  299. <virtual-o:
  300.     push(BSTACK_99,REXX_IN_BUF)
  301.     pop(BSTACK_99,SEARCH_STR)
  302.     setsearch(SEARCH_STR)
  303.     runkey(normal-f9) >
  304.  
  305. The 'message' macro  Usage: message 'my message'
  306. issue a message
  307. <virtual-p:    putmsg(REXX_IN_BUF) >
  308.  
  309.  
  310. <defines: >
  311.